com.cete.dynamicpdf
Class DocumentJavaScriptList



Example: The following example shows how to use DcoumentJavaScriptList class.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.Label;
 
public class MyClass{
        public static void main(String args[]) {
        // Create a document and set it's properties
        Document document = new Document();
        
        // Create a page to add to the document
        Page page = new Page( PageSize.LETTER, PageOrientation.PORTRAIT, 54.0f );
        
        // Create a Label to add to the page
        String text = "JavaScript Example";
        Label label = new Label( text, 0, 0, 504, 100, Font.getHelvetica(), 18, TextAlign.CENTER );
        
        // Add the JavaScript alert to the Document
        document.getJavaScripts().add( new DocumentJavaScript( "HelloWorld", "app.alert(\"Hello World!!\")" ) );
        
        // Add label to page
        page.getElements().add( label );
        
        // Add page to document
        document.getPages().add( page );
        
        // Save the PDF document
        document.draw("[PhysicalPath]/MyDocument.pdf");
    }
 }